home *** CD-ROM | disk | FTP | other *** search
- unit Viewform;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Printers, HTTPApp;
-
- type
- TCCForm = class(TForm)
- Memo1: TMemo;
- Panel1: TPanel;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Edit1: TEdit;
- Label1: TLabel;
- Edit2: TEdit;
- Label2: TLabel;
- BitBtn3: TBitBtn;
- ComboBox1: TComboBox;
- Label3: TLabel;
- ComboBox2: TComboBox;
- Label4: TLabel;
- PageProducer1: TPageProducer;
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure ComboBox1Change(Sender: TObject);
- procedure PageProducer1HTMLTag(Sender: TObject; Tag: TTag;
- const TagString: String; TagParams: TStrings;
- var ReplaceText: String);
- private
- { Private declarations }
- procedure SetFileToShow(Value: string);
- public
- { Public declarations }
- property FileToShow: string write SetFileToShow;
- end;
-
- var
- CCForm: TCCForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TCCForm.SetFileToShow(Value: string);
- begin
- Memo1.Lines.Clear;
- Memo1.Lines.LoadFromFile(Value);
- end;
-
- procedure TCCForm.BitBtn1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TCCForm.BitBtn2Click(Sender: TObject);
- var
- F: TextFile;
- i: integer;
- begin
- { print memo.lines }
- Printer.Title := 'Form Print Demo';
- Printer.Canvas.Font.Name := ComboBox2.Text;
- Printer.Canvas.Font.Size := 10;
- AssignPrn(F);
- Rewrite(F);
- try
- for i := 0 to Memo1.Lines.Count-1 do
- Writeln(F, Memo1.Lines[i]);
- finally
- CloseFile(F);
- end;
- end;
-
- procedure TCCForm.FormShow(Sender: TObject);
- begin
- { set screen elements }
- ComboBox1.Items.Assign(Screen.Fonts);
- ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(Memo1.Font.Name);
- ComboBox2.Items.Assign(Printer.Fonts);
- ComboBox2.ItemIndex := ComboBox2.Items.IndexOf(Memo1.Font.Name);
- Memo1.Text := PageProducer1.Content;
- end;
-
- procedure TCCForm.ComboBox1Change(Sender: TObject);
- begin
- Memo1.Font.Name := ComboBox1.Text;
- ComboBox2.ItemIndex := ComboBox2.Items.IndexOf(Memo1.Font.Name);
- end;
-
- procedure TCCForm.PageProducer1HTMLTag(Sender: TObject; Tag: TTag;
- const TagString: String; TagParams: TStrings; var ReplaceText: String);
- begin
- if Pos('Product', TagString) <> 0 then
- ReplaceText := Format('%-*s', [Length(TagString)+3, Edit1.Text]);
-
- if Pos('Size', TagString) <> 0 then
- ReplaceText := Format('%*s', [Length(TagString)+3, Edit2.Text]);
-
- if Pos('Date', TagString) <> 0 then
- ReplaceText := Format('%-*s', [Length(TagString)+3, DateToStr(Date)]);
- end;
-
- end.
-